﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;//UTF8编码的命名空间
using System.Security.Cryptography;//MD5的命名空间

namespace CocisDAL
{
    public class MakeMD5String
    {
        /// <summary>
        ///普通字符通过MD5加密方法、返回加密密文 
        /// </summary>
        /// <param name="oldString"></param>
        /// <returns></returns>
        public string StringToMD5(string oldString)
        {
            byte[] OldString = Encoding.UTF8.GetBytes(oldString);
            //计算UTF8编码的字节数组的MD5哈希值，再转换为字符串
            MD5 md5 = new MD5CryptoServiceProvider();
            string md5String = Encoding.UTF8.GetString(md5.ComputeHash(OldString));
            return md5String;
        }
    }
}
